<?

require_once("conf.php");
dbconnect();

# http://xzzy.org/taxtris/submit.php?id=bobvila&income=100000&spent=5600&taxes=1200&bpm=60&failures=5&score=242000

$id = safe_string($_GET['id']);
$income = safe_number($_GET['income']);
$spent = safe_number($_GET['spent']);
$taxes = safe_number($_GET['taxes']);
$bpm = safe_number($_GET['bpm']);
$failures = safe_number($_GET['failures']);
$score = safe_number($_GET['score']);
$deathpenalty = safe_number($_GET['deaths']);

$cnet = $income - $spent - $taxes;
$cdiff = $bpm / 10;

if($failures + $deathpenalty == 0) {
	$cbonus = $cdiff;
} else {
	$cbonus = $cdiff / ($failures + $deathpenalty);
}

$ctotal = $cnet * $cbonus;

$cheater = 0;
#if($ctotal != $score) {
#    $cheater = 1;
#}

$query = "insert into taxtris (username,submitdate,income,spent,taxes,bpm,failure,deathpenalty,score,cheater) values ('$id',NOW(),$income,$spent,$taxes,$bpm,$failures,$deathpenalty,$score,$cheater)";

dbquery($query);

echo $query;


?>
